/**
 * @file
 * @author  Tsin Smith <tsin.creator@gmail.com>
 *
 * @section DESCRIPTION
 *
 */

#ifndef __TSIN_DISPLAY_DECORATEDIMAGE_HPP__
#define __TSIN_DISPLAY_DECORATEDIMAGE_HPP__

#include <tsin/display/common.hpp>

#include <tsin/display/Display.hpp>
#include <tsin/util/Resolution.hpp>

namespace tsin {

        class DecoratedImage;
        struct ImageInfo;
        typedef void (*NextFrameHandler) (DecoratedImage *image, int prevTick, int curTick);

        class Image;

        class DISPLAY_DLLEXPORT DecoratedImage {
        public:
                DecoratedImage(Image &image);
                ~DecoratedImage();

                void init(ImageInfo *info);

                unsigned int getHandle();
                StandardResolution getResolution();

                /**
                 * @name Position
                 */
                //@{

                void setXRange(int left, int right);
                void setXRange(float left, float right);
                void setYRange(int bottom, int top);
                void setYRange(float bottom, float top);

                float left();
                float right();
                float bottom();
                float top();
                float width();
                float height();

                //@} Position

                /**
                 * @name Color
                 */
                //@{

                void setRGBA(float r, float g, float b, float a);
                void setBlendStyle(BlendStyle style);

                float r();
                float g();
                float b();
                float a();
                BlendStyle blendStyle();

                //@} Color

                /**
                 * @name Animation
                 */
                //@{

                void setNrFrames(int nrFrames);
                void setHandler(NextFrameHandler handler);
                void setFrame(int frame, bool update = true);
                void setReverse(bool reverse);

                int nrFrames();
                int curFrame();
                bool reversed();

                void nextFrame();
                //@} Animation

        protected:
                Image &image;

                float xLeft, xRight, yBottom, yTop;
                float _r, _g, _b, _a;
                BlendStyle _blendStyle;

                int _nrFrames, _curFrame;
                bool reverse;
                NextFrameHandler handler;
        };

}

#endif /* __TSIN_DISPLAY_DECORATEDIMAGE_HPP__ */
